import QtQuick 2.0

Item {
    id: root
    width: container.childrenRect.width + 16 //孩子的宽度
    height: container.childrenRect.height + 16 //孩子的长度
    property alias text: label.text
    property alias source: image.source
    signal clicked
    property bool framed: false
    property alias labelColor :label.color

    Rectangle {
        anchors.fill: parent
        color: "white"
        visible: root.framed
    }

    Column {
        x: 8
        y: 8
        id: container
        Image {
            id: image
        }
        Text {
            id: label
            width: image.width
            horizontalAlignment: Text.AlignHCenter
            wrapMode: Text.WordWrap //与图像一样宽并且可以自动换行
            color: "#ececec"
        }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: root.clicked()
    }
}
